<!DOCTYPE html>
<html>
<head>
    <title>WeiChatGPT</title>
</head>
<body>
<h1>WeiChatGPT-Query</h1><br>
<form id="myform">
    <label for="question">question:</label>
    <input type="text" id="question" name="question">

    <label for="fileName">fileName:</label>
    <input type="text" id="fileName" name="fileName">

    <input type="button" value="查询" onclick="ajax()"><br><br><br><br>
</form>


<label for="result">查询结果:</label><br>
<textarea id="result" readonly="readonly" rows="30px" cols="150"></textarea>

<script type="text/javascript">
    /*获取页面参数*/
    var question = document.getElementById("question").innerText;
    var fileName = document.getElementById("fileName").innerText;

    function ajax() {
        /*构建表单提交参数*/
        var formData = new FormData();
        formData.append("question", question);
        formData.append("fileName", fileName);

        /*构建ajax请求*/
        var xml = new XMLHttpRequest();
        xml.open("POST", "/chat/text", true);
        xml.onreadystatechange = function () {
            document.getElementById("result").innerHTML = xmlhttp.responseText;
        }
        xml.setRequestHeader("Content-type", "application/json;charset=UTF-8")
        xml.send(formData);
    }

</script>
</body>
</html>